<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Collect extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('collect', ['comment' => '用户采集表']);
        $table
            ->addColumn('area_id', 'integer', array('limit' => 11, 'default' => 0,'comment' => '所属区id'))
            ->addColumn('street_id', 'integer', array('limit' => 11, 'default' => 0,'comment' => '街道id'))
            ->addColumn('community_id', 'integer',array('limit' => 11,'default' => 0, 'comment' => '社区id'))
            ->addColumn('project_id', 'integer',array('limit' => 11,'default' => 0, 'comment' => '项目id'))
            ->addColumn('target_id', 'integer',array('limit' => 11,'default' => 0, 'comment' => '指标id'))
            ->addColumn('sample_id', 'integer',array('limit' => 11,'default' => 0, 'comment' => '样本点id'))
            ->addColumn('path', 'json',array('null'=>true,'comment' => '图片地址'))
            ->addColumn('uid', 'integer',array('limit' => 11,'default' => 0, 'comment' => '采集人'))
            ->addColumn('gather_company_id', 'integer',array('limit' => 11,'default' => 0, 'comment' => '包保单位or采集单位id'))
            ->addColumn('desc', 'string',array('limit' => 550,'null'=>true,'comment' => '描述'))
            ->addColumn('is_rectify', 'integer',array('limit' => 11,'default' => 0, 'comment' => '是否整改'))
            ->addColumn('case_grade', 'integer',array('limit' => 11,'default' => 0, 'comment' => '案件等级'))
            ->addColumn('address_name', 'string',array('limit' => 550,'null'=>true,'comment' => '位置名称'))
            ->addColumn('detail_address', 'string',array('limit' => 550,'null'=>true,'comment' => '详细地址'))
            ->addColumn('latitude', 'string',array('limit' => 150,'null'=>true,'comment' => '纬度'))
            ->addColumn('longitude', 'string',array('limit' => 150,'null'=>true,'comment' => '经度'))
            ->addColumn('status', 'boolean',array('limit' => 1, 'default' => 1, 'comment' => '状态1未审核2已审核(有效案件)3无效案件'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();

    }
}
